{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "23feae80",
   "metadata": {},
   "source": [
    "### 什么是动态图和静态图？"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "91516202",
   "metadata": {},
   "source": [
    ">在深度学习模型的构建中，存在两种不同的编程方式，代码编写和执行方式均不一样\n",
    ">\n",
    ">**动态图编程：** 采用python的编程风格，每一行代码均可以返回计算结果，前面的代码全都用的动态编程方式。\n",
    ">\n",
    ">**静态图编程：** 先编译在计算的方式，需要现在代码中预定义完整的神经网络结构，飞浆框架会将神经网络描述为 program 类型的数据结构，并对 program 进行编译优化，在调用之心功能区获得计算结果。\n",
    ">\n",
    ">动态图编程体验极佳，更易调试，但是因为采用python实施执行的方式，开销较大，在性能方面与C++有一定差距；静态图调试难度大，但是将python编写的神经网络预定义为 program 类型，在转为 C++ 的方式重新解析，脱离了 python 的依赖，往往执行更佳，并且预先拥有完整网络结构也利于全局优化。\n",
    ">"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c58907d0",
   "metadata": {},
   "source": [
    "### 什么场景下需要动态图转静态图？"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2bee9cc7",
   "metadata": {},
   "source": [
    ">飞浆框架支持【动静统一】的方案：\n",
    ">\n",
    ">**在模型开发的时候，推荐采用动态图编程。** 可以获得更好的编程体验，更易用的接口，更好的调试交互机制。\n",
    ">\n",
    ">**在模型训练或者推理部署的时候，只需添加一行代码 @to_static，即可将动态图代码转为静态图代码，并在底层自动使用静态图执行器运行。** 可获得更好的运行性能。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2be4f73f",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f6e1a05f",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c2fe30f9",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
